package com.btcode.web.freemarker.errorhandle;

import com.btcode.web.core.errorhandle.IErrorHandler;
import java.io.IOException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

public class DefaultFreeMarkerErrorHandler implements IErrorHandler {

    @Override
    public void handleError(ServletRequest arg0, ServletResponse arg1, Throwable throwable) {
        StringBuffer strBuf = new StringBuffer();
        strBuf.append("<html>");
        strBuf.append("<head>");
        strBuf.append("<title>错误</title>");
        strBuf.append("</head>");
        strBuf.append("<body>");
        strBuf.append("<div>页面请求错误</div>");
        strBuf.append("</body>");
        strBuf.append("</html>");

        try {
            arg1.getWriter().write(strBuf.toString());
            arg1.getWriter().flush();
        }
        catch (IOException e1) {
            e1.printStackTrace();
        }
    }

}